//
//  LGFollowUpHomeCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/6/13.
//  病情概况 -- 随访记录

#import "LGFollowUpHomeCell.h"
#import "LGDottedLineView.h"
@interface LGFollowUpHomeCell()
/**   */
@property (nonatomic , strong)UIButton *indexBtn;
/**   */
@property (nonatomic , strong)UIButton *titleBtn;
/**   */
@property (nonatomic , strong)UIButton *dateBtn;
/**   */
@property (nonatomic , strong)UIView *cornerView;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;
/**   */
@property (nonatomic , strong)LGDottedLineView *lineView;

@end

@implementation LGFollowUpHomeCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    [self.titleBtn setTitle:[NSString stringWithFormat:@"%@.%@",dataDic[@"followup_no"],dataDic[@"followup_title"]] forState:UIControlStateNormal];
    [self.dateBtn setTitle:LGNSString(dataDic[@"followup_date"]) forState:UIControlStateNormal];
    [self.dateBtn setButtonInsetsStyle:LGButtonInsetsStyleRight marginSpace:3];
    self.contentLabel.text = LGNSString(dataDic[@"followup_content"]);
    self.titleBtn.selected = ([dataDic[@"followup_type"] integerValue] == 1)?YES:NO;
    self.dateBtn.selected = ([dataDic[@"followup_type"] integerValue] == 1)?YES:NO;
    [self.lineView setNeedsDisplay];
}

-(void)createSubView{
    self.contentView.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self.contentView addSubview:self.indexBtn];
    [self.contentView addSubview:self.titleBtn];
    [self.contentView addSubview:self.dateBtn];
    [self.contentView addSubview:self.cornerView];
    [self.cornerView addSubview:self.contentLabel];
    [self.contentView addSubview:self.lineView];
    [self.cornerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(46));
        make.right.equalTo(self.contentView).offset(-viewPix(20));
        make.top.equalTo(self.indexBtn.mas_bottom).offset(viewPix(15));
        make.bottom.equalTo(self.contentView).offset(-viewPix(12));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.cornerView).offset(viewPix(10));
        make.left.equalTo(self.cornerView).offset(viewPix(12));
        make.right.equalTo(self.cornerView).offset(-viewPix(12));
        make.bottom.equalTo(self.cornerView).offset(-viewPix(10));
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.indexBtn.mas_bottom);
        make.centerX.equalTo(self.indexBtn);
        make.bottom.equalTo(self.contentView);
        make.width.equalTo(@(1));
    }];
}

-(UIButton *)indexBtn{
    if(!_indexBtn){
        _indexBtn = [UIButton buttonWithImage:@"随访记录-圆圈" selectImage:@"随访记录-圆圈"];
        _indexBtn.frame = CGRectMake(viewPix(24), viewPix(7), 6, 6);
        _indexBtn.userInteractionEnabled = NO;
    }
    return _indexBtn;
}

-(UIButton *)titleBtn{
    if(!_titleBtn){
        _titleBtn = [UIButton buttonWithTitle:@"" titleFont:LGFontWeight(15, UIFontWeightMedium) normalColor:@"#333333" selectColor:@"#3291FF"];
        _titleBtn.frame = CGRectMake(kMaxX(self.indexBtn.frame)+viewPix(12), 0, viewPix(150), viewPix(21));
        _titleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _titleBtn.userInteractionEnabled = NO;
    }
    return _titleBtn;
}

-(UIButton *)dateBtn{
    if(!_dateBtn){
        _dateBtn = [UIButton buttonWithTitle:@"" titleFont:LGFont(15) normalColor:@"#666666" selectColor:@"#3291FF"];
        _dateBtn.frame = CGRectMake(Screen_W-viewPix(130), 0, viewPix(110), viewPix(21));
        [_dateBtn setImage:[UIImage imageNamed:@"grayTip12"] forState:UIControlStateNormal];
        [_dateBtn setImage:[UIImage imageNamed:@"blueTip12"] forState:UIControlStateSelected];
        _dateBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        _dateBtn.userInteractionEnabled = NO;
    }
    return _dateBtn;
}

-(UIView *)cornerView{
    if(!_cornerView){
        _cornerView = [[UIView alloc] init];
        _cornerView.backgroundColor = [UIColor colorWithString:@"#F0F7FF"];
        _cornerView.cornerRidus = 7;
    }
    return _cornerView;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _contentLabel;
}

-(LGDottedLineView *)lineView{
    if(!_lineView){
        _lineView = [[LGDottedLineView alloc] init];
        _lineView.lineColor = @"#88BC93";
        _lineView.lineDirection = @"vertical";
    }
    return _lineView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
